package com.basicorm.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class StringUtils {

	public static String join(String separator, Collection<String> collection) {
		StringBuilder result = new StringBuilder();
		Iterator<String> it = collection.iterator();
		while (it.hasNext()){
			result.append(it.next());
			if (it.hasNext()){
				result.append(separator);
			}
		}
		return result.toString();
	}
	
	public static String join(String separator, String... resultList) {
		return join(separator, Arrays.asList(resultList));
	}

	public static Collection<String> quote(Collection<String> collection) {
		Collection<String> tmp = new ArrayList();
		Iterator<String> it = collection.iterator();
		while (it.hasNext()){
			tmp.add("'" + it.next() + "'");
		}
		return tmp;
	}

}
